package com.Questions.DFS;

import java.util.*;
/**
 * 后序遍历
 */
public class leetcode145 {
    public List<Integer> postorderTraversal(TreeNode root) {
        List<Integer> res=new ArrayList<>();
        return traveTree(root,res);
    }
    public List<Integer> traveTree(TreeNode root,List<Integer> res){
        if(root==null){
            return res;
        }
        traveTree(root.left,res);
        traveTree(root.right,res);
        res.add(root.val);
        return res;
    }

}
